import { LogisticsNodes } from '../../../services/order/order';

Page({
  data: {
    logisticsData: {
      nodes: [],
      deliveryType: '',
      deliveryName: '',
      deliveryNo: ''
    },
    active: 0,
    emptyImg: 'https://cdn-we-retail.ym.tencent.com/miniapp/order/empty-order-list.png',
    showEmpty: false
  },
  /* 物流轨迹 */
  getLogisticsNodes(orderId) {
    LogisticsNodes({ orderId }).then(res => {
      if (res.code === '0000') {
        if (res.data && res.data[0].deliveryContentList) {
          res.data[0].deliveryContentList = res.data[0].deliveryContentList.reverse()
          this.setData({ logisticsData: res.data[0], active: res.data[0].deliveryContentList.length });
        } else this.setData({ showEmpty: true })
      }
    })
  },
  onLoad(query) {
    this.getLogisticsNodes(query.orderId)
  },

  onLogisticsNoCopy() {
    wx.setClipboardData({ data: this.data.logisticsData.deliveryNo });
  },
});
